package top.fishmovie.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;
import java.util.List;


@RestController
public class RecommendController {

    @RequestMapping(value= "/recommend/", method= RequestMethod.GET)
    public ResponseEntity<List<RecommendMovie>> recommend(){
        List<RecommendMovie> movies = new LinkedList<RecommendMovie>();

        String[] names = {"Toy Story", "Jumanji", "Grumpier Old Men", "Waiting to Exhale",
                "Father of the Bride Part II", "Heat", "Sabrina", "Tom and Huck", "Sudden Death",
               "GoldenEye"};
        String[] urls = {
                "http://image.tmdb.org/t/p/w185/rhIRbceoE9lR4veEXuwCC2wARtG.jpg",
                "http://image.tmdb.org/t/p/w185/8wBKXZNod4frLZjAKSDuAcQ2dEU.jpg",
                "http://image.tmdb.org/t/p/w185/6ksm1sjKMFLbO7UY2i6G1ju9SML.jpg",
                "http://image.tmdb.org/t/p/w185/16XOMpEaLWkrcPqSQqhTmeJuqQl.jpg",
                "http://image.tmdb.org/t/p/w185/e64sOI48hQXyru7naBFyssKFxVd.jpg",
                "http://image.tmdb.org/t/p/w185/zMyfPUelumio3tiDKPffaUpsQTD.jpg",
                "http://image.tmdb.org/t/p/w185/jQh15y5YB7bWz1NtffNZmRw0s9D.jpg",
                "http://image.tmdb.org/t/p/w185/sGO5Qa55p7wTu7FJcX4H4xIVKvS.jpg",
                "http://image.tmdb.org/t/p/w185/eoWvKD60lT95Ss1MYNgVExpo5iU.jpg",
                "http://image.tmdb.org/t/p/w185/5c0ovjT41KnYIHYuF4AWsTe3sKh.jpg"
        };
        for(int i = 0; i < 10; i++){
            RecommendMovie movie = new RecommendMovie();
            movie.setName(names[i]);
            movie.setObjectId(i + 10000);
            movie.setScore(i + 5);
            movie.setPicUrl(urls[i]);
            movies.add(movie);
        }
        return new ResponseEntity(movies,HttpStatus.OK);
    }

    @RequestMapping(value= "/recommend/{token}", method= RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<List<RecommendMovie>> recommend4user(@PathVariable("token") Long token){
        List<RecommendMovie> movies = new LinkedList<RecommendMovie>();

        String[] names = {"Toy Story", "Jumanji", "Grumpier Old Men", "Waiting to Exhale",
                "Father of the Bride Part II", "Heat", "Sabrina", "Tom and Huck", "Sudden Death",
                "GoldenEye"};
        String[] urls = {
                "http://image.tmdb.org/t/p/w185/rhIRbceoE9lR4veEXuwCC2wARtG.jpg",
                "http://image.tmdb.org/t/p/w185/8wBKXZNod4frLZjAKSDuAcQ2dEU.jpg",
                "http://image.tmdb.org/t/p/w185/6ksm1sjKMFLbO7UY2i6G1ju9SML.jpg",
                "http://image.tmdb.org/t/p/w185/16XOMpEaLWkrcPqSQqhTmeJuqQl.jpg",
                "http://image.tmdb.org/t/p/w185/e64sOI48hQXyru7naBFyssKFxVd.jpg",
                "http://image.tmdb.org/t/p/w185/zMyfPUelumio3tiDKPffaUpsQTD.jpg",
                "http://image.tmdb.org/t/p/w185/jQh15y5YB7bWz1NtffNZmRw0s9D.jpg",
                "http://image.tmdb.org/t/p/w185/sGO5Qa55p7wTu7FJcX4H4xIVKvS.jpg",
                "http://image.tmdb.org/t/p/w185/eoWvKD60lT95Ss1MYNgVExpo5iU.jpg",
                "http://image.tmdb.org/t/p/w185/5c0ovjT41KnYIHYuF4AWsTe3sKh.jpg"
        };
        for(int i = 0; i < 5; i++){
            RecommendMovie movie = new RecommendMovie();
            movie.setName(names[i]);
            movie.setObjectId(i + 10000);
            movie.setScore(i + 5);
            movie.setPicUrl(urls[i]);
            movies.add(movie);
        }
        return new ResponseEntity(movies,HttpStatus.OK);
    }
}
